import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  // 登录
  {
    path: "/login/login",
    component: () => import("../views/login/login"),
    meta: {
      title: "用户登录",
      showtab: false
    }
  },
  // 忘记密码
  {
    path: "/login/forgetpass",
    component: () => import("../views/login/forgetpass"),
    meta: {
      title: "忘记密码",
      showtab: false
    }
  },
  // 上单登录
  {
    path: "/login/auditlogin",
    component: () => import("../views/login/auditlogin"),
    meta: {
      title: "上单登录",
      showtab: false
    }
  },
  // 淘礼金
  {
    path: "/optimGoods/taocashgift",
    component: () => import("../views/optimGoods/taocashgift/index"),
    meta: {
      title: "淘礼金",
      showtab: false
    }
  },
  // 优选库
  {
    path: "/optimGoods",
    component: () => import("@/views/optimGoods/index"),
    redirect: "/optimGoods/optimBank",
    meta: {
      showtab: false,
      title: "优选库"
    },
    children: [
      {
        path: "optimBank",
        name: "optimBank",
        component: () => import("@/views/optimGoods/optimBank/index"),
        meta: {
          title: "优选库"
        }
      },
      {
        path: "nowList",
        name: "nowList",
        component: () => import("@/views/optimGoods/nowList/index"),
        meta: {
          title: "实时榜单"
        }
      },
      {
        path: "siftGoods",
        name: "siftGoods",
        component: () => import("@/views/optimGoods/siftGoods/index"),
        meta: {
          title: "全部商品"
        }
      },
      {
        path: "meatlive",
        name: "meatlive",
        component: () => import("@/views/optimGoods/meatlive/index"),
        meta: {
          title: "肉单直播"
        }
      },
      {
        path: "widge",
        name: "widge",
        redirect: "/optimGoods/widge/widgepic",
        component: () => import("@/views/optimGoods/widge/index"),
        meta: {
          title: "小工具"
        },
        children: [
          {
            path: "widgepic",
            name: "widgepic",
            component: () => import("@/views/optimGoods/widge/widgepic"),
            meta: {
              title: "营销图制作"
            }
          }
        ]
      },
      {
        path: "goodsDetails",
        name: "goodsDetails",
        component: () => import("../views/optimGoods/goodsDetails/index"),
        meta: {
          title: "商品详情"
        }
      }
    ]
  },
  // 个人中心
  {
    path: "/userinfo",
    redirect: "/userinfo/homepage",
    component: () => import("@/views/userinfo/index"),
    children: [
      {
        path: "homepage",
        name: "homepage",
        component: () => import("@/views/userinfo/homepage/index"),
        meta: {
          title: "首页"
        }
      },
      {
        path: "upgoodshome",
        name: "upgoodshome",
        component: () => import("@/views/userinfo/upgoodshome/index"),
        meta: {
          title: "上单首页"
        }
      },
      {
        path: "atduhome",
        name: "atduhome",
        component: () => import("@/views/userinfo/atduhome/index"),
        meta: {
          title: "审核首页"
        }
      },
      {
        path: "adminhome",
        name: "adminhome",
        component: () => import("@/views/userinfo/adminhome/index"),
        meta: {
          title: "管理首页"
        }
      },
      // 用户后台
      {
        path: "goodsmanage",
        name: "goodsmanage",
        component: () => import("@/views/userinfo/goodsmanage/index"),
        meta: {
          title: "商品管理"
        }
      },
      {
        path: "teamset",
        name: "teamset",
        component: () => import("@/views/userinfo/teamset/index"),
        meta: {
          title: "团队设置"
        }
      },
      {
        path: "pid",
        name: "pid",
        component: () => import("@/views/userinfo/tbpid/index"),
        meta: {
          title: "淘宝授权"
        }
      },
      //黑名单
      {
        path: "blacklist",
        component: () => import("../views/userinfo/blacklist/index"),
        meta: {
          title: "黑名单",
          showtab: false
        }
      },
      {
        path: "report",
        component: () => import("../views/userinfo/blacklist/report"),
        meta: {
          title: "我要举报",
          showtab: false
        }
      },
      {
        path: "myReport",
        component: () => import("../views/userinfo/blacklist/myreport"),
        meta: {
          title: "我的举报",
          showtab: false
        }
      },
      {
        path: "newsNotice",
        component: () => import("../views/userinfo/newsnotice/index"),
        meta: {
          title: "消息通知",
          showtab: false
        }
      },
      // 上单后台
      {
        path: "uporder",
        name: "uporder",
        component: () => import("@/views/userinfo/uporder/index"),
        meta: {
          title: "发布新单"
        }
      },
      {
        path: "addgoods",
        name: "addgoods",
        component: () => import("@/views/userinfo/uporder/addgoods.vue"),
        meta: {
          title: "新增商品"
        }
      },
      {
        path: "upgoods",
        name: "upgoods",
        component: () => import("@/views/userinfo/upgoods/index"),
        meta: {
          title: "上单商品管理"
        }
      },
      {
        path: "tickling",
        name: "tickling",
        component: () => import("@/views/userinfo/tickling/index"),
        meta: {
          title: "商品反馈"
        }
      },
      {
        path: "taogifts",
        name: "taogifts",
        component: () => import("@/views/userinfo/taogifts/index"),
        meta: {
          title: "淘礼金"
        }
      },
      // 后台上单
      {
        path: "auditpage",
        name: "auditpage",
        component: () => import("@/views/userinfo/auditpage/index"),
        meta: {
          title: "商品审核"
        }
      },
      {
        path: "audituser",
        name: "audituser",
        component: () => import("@/views/userinfo/audituser/index"),
        meta: {
          title: "用户审核"
        }
      },
      // 后台管理
      {
        path: "managepage",
        name: "managepage",
        component: () => import("@/views/userinfo/managepage/index"),
        meta: {
          title: "管理后台"
        }
      },
      {
        path: "articlemanage",
        name: "articlemanage",
        component: () => import("@/views/userinfo/articlemanage/index"),
        meta: {
          title: "文章管理"
        }
      },
      {
        path: "noticemansge",
        name: "noticemansge",
        component: () => import("@/views/userinfo/noticemansge/index"),
        meta: {
          title: "公告管理"
        }
      },
      {
        path: "yxactive",
        name: "yxactive",
        component: () => import("@/views/userinfo/yxactive/index"),
        meta: {
          title: "营销活动"
        }
      },
      {
        path: "dashboard",
        name: "dashboard",
        component: () => import("@/views/userinfo/dashboard/index"),
        meta: {
          title: "控制台"
        }
      },
      {
        path: "accountmanage",
        name: "accountmanage",
        component: () => import("@/views/userinfo/accountmanage/index"),
        meta: {
          title: "上单账号管理"
        }
      },
      {
        path: "datastatistics",
        name: "datastatistics",
        component: () => import("@/views/userinfo/datastatistics/index"),
        meta: {
          title: "上单数据统计"
        }
      },
      {
        path: "rejectreason",
        name: "rejectreason",
        component: () => import("@/views/userinfo/rejectreason/index"),
        meta: {
          title: "拒绝理由"
        }
      }
    ]
  },
  // 帮助中心
  {
    path: "/helper",
    component: () => import("../views/optimGoods/helper/index"),
    meta: {
      title: "帮助中心",
      showtab: false
    }
  }
];
// 解决路由二次点击报错 (原因 4.0+不允许push重复路由)
const VueRouterPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err);
};
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
});

export default router;
